module ALUControl(CLK, ALUop, FuncCode/* Opcode*/, ALUCtrl);

	input CLK;
    input [3:0] ALUop;
    input [5:0] FuncCode;
	//input [5:0] Opcode;
	
    output [3:0] ALUCtrl;

	reg [3:0] ALUCtrl;

always @ (negedge CLK or ALUop or FuncCode) begin
	$display($time, "ALUControl:  ALUCtrl=%b, ALUop=%b FuncCode=%b", ALUCtrl, ALUop,FuncCode);
	
if (ALUop == 'b1111) begin
	case (FuncCode)
				'b100000 : 
							begin
							ALUCtrl <= 'b0111;//OPCODE_ADD
							end
				'b100001 : 
							begin
							ALUCtrl <= 'b0001;//OPCODE_ADDU
							end
				'b100010 : 
							begin
							ALUCtrl <= 'b0010;//OPCODE_SUB
							end
				'b100010 : 
							begin
							ALUCtrl <= 'b0110;//OPCODE_SUB
							end
				'b100010 :
							begin
							ALUCtrl <= 'b0011;//OPCODE_SUBU
							end
				'b100100 : 
							begin
							ALUCtrl <= 'b0100;//OPCODE_AND
							end
				'b100101 :
							begin
							ALUCtrl <= 'b0101;//OPCODE_OR
							end
				'b000011 : 
							begin
							ALUCtrl <= 'b1101;//OPCODE_SRA
							
							end
				'b101010 : 
							begin
							ALUCtrl <= 'b1010;//OPCODE_SLT
							end
				'b101011 : 
							begin
							ALUCtrl <= 'b1011;//OPCODE_SLTU
							end
				'b000000 :
							begin
							ALUCtrl <= 'b1100;//OPCODE_SLL
							end
				'b000010 :
							begin
							ALUCtrl <= 'b1001;//OPCODE_SRL
							end
				'b001100 : 
							begin
							ALUCtrl <=4'b0000;
							end
			endcase 
end

else begin
			ALUCtrl <= ALUop;
end
	$display($time, "ALUCtrl=%b, ALUop=%b", ALUCtrl, ALUop);

end 
endmodule
